﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace ChequeManagement.BLL
{
    /// <summary>
    /// This Class Includes Field, constructor, Method 
    /// </summary>
    /// <Field>this field name is "dataObject" and type is DAL.DALChequeCategoryWithPARI and use this field on methods</Field>
    /// <Method>this class includes some method for add,edit,getall,remove data</Method>
    /// <constructor>this class include a constructor that one not have overload</constructor>
    public class BLLChequeCategoryWithPARIFactory
    {
        private DAL.DALChequeCategoryWithPARI dataObject = new DAL.DALChequeCategoryWithPARI();

        #region Methods
        /// <summary>
        /// This constructor not have parameter and use on create instance of class
        /// </summary>
        public BLLChequeCategoryWithPARIFactory()
        {
        }

        /// <summary>
        /// This method get a object that type is BLLChequeCategoryWithPARI and create a instance of DAL.DALChequeCategoryWithPARI class and call Insert method and set parameter
        /// </summary>
        /// <param name="chequeCategoryWithPARIObj" Type="BLLChequeCategoryWithPARI"></param>
        /// <return>this type is void and Do not return</return>
        public void Add(BLLChequeCategoryWithPARI chequeCategoryWithPARIObj)
        {
            try
            {
                dataObject.Insert(chequeCategoryWithPARIObj);
            }
            catch (Exception ex)
            {

                throw (ex);
            }
        }

        /// <summary>
        /// This method get a object that type is BLLChequeCategoryWithPARI and a object that type is int
        /// this method call dataObject that type is DAL.DALChequeCategoryWithPARI and call Update method and set parameter 
        /// </summary>
        /// <param name="chequeCategoryWithPARIObj" Type="BLLChequeCategoryWithPARI"></param>
        /// <param name="targetChequeNo" Type="int"></param>
        /// <return>this type is void and Do not return</return>
        public void Edit(BLLChequeCategoryWithPARI chequeCategoryWithPARIObj, int targetChequeNo)
        {
            try
            {
                dataObject.Update(chequeCategoryWithPARIObj, targetChequeNo);
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }

        /// <summary>
        /// This method not have  parameter 
        /// this method call dataObject that type is DAL.DALChequeCategoryWithPARI and call FetchAll method and set parameter 
        /// </summary>
        /// <returns>this method select data and result return into DataTable</returns>
        public void GetAll( DataTable datatable)
        {
            try
            {
                dataObject.FetchAll(datatable);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// This method not have parameter
        /// and call dataObject that type is DAL.DALChequeCategoryWithPARI and call FetchAll method for select all data
        /// </summary>
        /// <returns>this method select all data and result return into List<> that type is BLLChequeCategoryWithPARI</returns>
        public List<BLLChequeCategoryWithPARI> GetAll()
        {
            try
            {
                return dataObject.FetchAll();
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }

        /// <summary>
        /// This method have parameters
        /// and call dataObject that type is DAL.DALChequeCategoryWithPARI and call FetchByField method and set parameters
        /// the filedname parameter select field name on select table and vlaue parameter select value that select field name
        /// </summary> 
        /// <param name="fieldName" Type="string"></param>
        /// <param name="value" Type="object"></param>
        /// <returns>this method select data and result return into List<> that type is BLLChequeCategoryWithPARI</returns>
        public List<BLLChequeCategoryWithPARI> GetByField(string fieldName, object value)
        {
            try
            {
                return dataObject.FetchByField(fieldName, value);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// This method have parameters
        /// and call dataObject that type is DAL.DALChequeCategoryWithPARI and call FetchByField method and set parameters
        /// the filedname parameter select field name on select table and vlaue parameter select value that select field name and result return into dt parameter 
        /// </summary>
        /// <param name="fieldName" Type="string"></param>
        /// <param name="value" Type="object"></param>
        /// <param name="dt" Type="DataTable"></param>
        /// <return>this type is void and Do not return but parameter is DataTable and result return into this DataTable</return>
        public void GetByField(string fieldName, object value, DataTable dt)
        {
            try
            {
                dataObject.FetchByField(fieldName, value, dt);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// This method have parameter
        /// and call dataObject that type is DAL.DALChequeCategoryWithPARI and call FetchByKey method and set parameters
        /// select data by targetChequeNo
        /// </summary>
        /// <param name="targetChequeNo" Type="int"></param>
        /// <returns>object that type is BLLChequeCategoryWithPARI</returns>
        public BLLChequeCategoryWithPARI GetByKey(int targetChequeNo)
        {
            try
            {
                return dataObject.FetchByKey(targetChequeNo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// This method have parameter
        /// and call dataObject that type is DAL.DALChequeCategoryWithPARI and call Delete method and set parameters
        /// </summary>
        /// <param name="targetChequeNo"></param>
        /// <return>this type is void and Do not return</return>
        public void Remove(int targetChequeNo)
        {
            try
            {
                dataObject.Delete(targetChequeNo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void GetAllByCondition(string condition, ref DataTable dataTable)
        {
            try
            {
                dataObject.FetchAllByCondition(condition, dataTable);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }

        public void Remove(string fieldName, object value)
        {
            try
            {
                dataObject.Delete(fieldName, value);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
        #endregion

    }
}
